package simpleHttpClient;

import java.util.Comparator;
/**
 * compare url based on the host name;
 * @author Weihan li
 *
 *@version 1.1
 */
public class URLComparator implements Comparator<Request> {
	/**
	 * compare the host name of two Rquest, basically we just need two same host name stay together;
	 */
	@Override
	public int compare(Request req1, Request req2){
		String url1=req1.getHostName();
		String url2=req2.getHostName();
		int compare;
		if (url1.equals(url2)){
			compare=0;
		}
		else{
			if(url1.length()>=url2.length()){
				compare=1;				
			}else{
				compare=-1;
			}
		}
		return compare;
	}



}
